package xyz.o0o0o.demo.AuthorizationServerDemo2.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;

import xyz.o0o0o.demo.AuthorizationServerDemo2.dao.UserDao;
import xyz.o0o0o.demo.AuthorizationServerDemo2.entity.CustomUserDetails;
import xyz.o0o0o.demo.AuthorizationServerDemo2.entity.User;
import xyz.o0o0o.demo.AuthorizationServerDemo2.service.UserService;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;

	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		System.out.println("UserServiceImpl loadUserByUsername");
		User user = userDao.select(username);
		System.out.println("user:"+JSON.toJSON(user));
		return new CustomUserDetails(user);
	}

}
